import request from '@/utils/axios'

// 获取菜单列表
export function listMenu(params: any) {
  return request({
    url: '/system/menu/list',
    method: 'get',
    params
  })
}

// 获取菜单详情
export function getMenu(id) {
  return request({
    url: `/system/menu/${id}`,
    method: 'get'
  })
}

// 添加菜单
export function addMenu(data) {
  return request({
    url: '/system/menu',
    method: 'post',
    data
  })
}

// 修改菜单
export function updateMenu(data) {
  return request({
    url: '/system/menu',
    method: 'put',
    data
  })
}

// 删除菜单
export function delMenu(id) {
  return request({
    url: `/system/menu/${id}`,
    method: 'delete'
  })
}

// 查询菜单下拉树结构
export function getMenuTreeSelect() {
  return request({
    url: '/system/menu/getTreeSelect',
    method: 'get'
  })
}

// 根据角色id查询对应的下拉菜单树结构
export function getTreeSelectByRoleId(id) {
  return request({
    url: `/system/menu/getTreeSelectByRoleId/${id}`,
    method: 'get'
  })
}
